package com.jiukuaidao.zhulin.util;

import android.content.SharedPreferences;

import com.jiukuaidao.library.Config;
import com.jiukuaidao.zhulin.entity.ApiHomePros;

/**
 * Author : H_Joker
 * Date : 2016/6/30
 * Description :
 */
public class ShopInfoUtil {

    /**
     * 设置店铺信息
     *
     * @param shopInfo
     */
    public static void setShopInfo(ApiHomePros.ApiHomeShop shopInfo) {
        SharedPreferences settings = Config.mContext.getSharedPreferences("shopInfo", 0);
        SharedPreferences.Editor editor = settings.edit();
        if (shopInfo != null) {
            editor.putString("cityCode", shopInfo.cityCode);
            editor.putString("closeTime", shopInfo.closeTime);
            editor.putString("deliveryLimit", shopInfo.deliveryLimit);
            editor.putString("id", shopInfo.id);
            editor.putInt("isOpen", shopInfo.isOpen);
            editor.putString("latitude", shopInfo.latitude);
            editor.putString("logo", shopInfo.logo);
            editor.putString("longitude", shopInfo.longitude);
            editor.putString("mobile", shopInfo.mobile);
            editor.putString("name", shopInfo.name);
            editor.putString("openTime", shopInfo.openTime);
            editor.putString("deliveryPrice",shopInfo.deliveryPrice);//配送费用
            editor.putString("deliveryFreeLimit",shopInfo.deliveryFreeLimit);
        }
        editor.commit();
    }

    /**
     * 获取起送价
     *
     * @return
     */
    public static String getDeliveryLimit() {
        SharedPreferences settings = Config.mContext.getSharedPreferences("shopInfo", 0);
        String deliveryLimit = settings.getString("deliveryLimit", "");
        return deliveryLimit;
    }

    /**
     * 清除店铺信息
     */
    public static void clearShopInfo() {
        SharedPreferences settings = Config.mContext.getSharedPreferences("shopInfo", 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.clear();
    }

    /**
     * 获取店铺配送金额
     */
    public static String getFullShipmentFree(){

        SharedPreferences settings = Config.mContext.getSharedPreferences("shopInfo", 0);
        String deliveryPrice = settings.getString("deliveryFreeLimit", "");
        return deliveryPrice;
    }

    /**
     *
     * 获取店铺运费
     * @return
     */
    public static String getDeliveryPrice(){

        SharedPreferences settings = Config.mContext.getSharedPreferences("shopInfo", 0);
        String deliveryPrice = settings.getString("deliveryPrice", "");
        return deliveryPrice;

    }

    /**
     * 获取店铺id
     *
     * @return
     */
    public static String getShopId() {
        SharedPreferences settings = Config.mContext.getSharedPreferences("shopInfo", 0);
        String id = settings.getString("id", "");
        return id;
    }
}
